package com.example.administrator.nl.activity.appointment;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.example.administrator.nl.R;
import com.example.administrator.nl.adapter.AppointmentAdapter;
import com.example.administrator.nl.base.BaseActivity;
import com.example.administrator.nl.bean.AppointmentBean;
import com.example.administrator.nl.util.ToastUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 预约
 *
 * @author yuan
 */
public class AppointmentActivity extends BaseActivity implements View.OnClickListener {
    @BindView(R.id.iv_finish_appointment)
    ImageView iv_finish_appointment;

    @BindView(R.id.tv_comment_appointment)
    TextView tv_comment_appointment;

    @BindView(R.id.tv_distance_appointment)
    TextView tv_distance_appointment;

    @BindView(R.id.recycler_view)
    RecyclerView recyclerView;

    private AppointmentAdapter appointmentAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        iv_finish_appointment.setOnClickListener(this);
        tv_comment_appointment.setOnClickListener(this);
        tv_distance_appointment.setOnClickListener(this);
    }

    @Override
    public void init() {
        List<AppointmentBean> list = new ArrayList<>();
        list.add(new AppointmentBean());
        list.add(new AppointmentBean());
        list.add(new AppointmentBean());
        list.add(new AppointmentBean());
        list.add(new AppointmentBean());
        list.add(new AppointmentBean());
        list.add(new AppointmentBean());
        list.add(new AppointmentBean());
        list.add(new AppointmentBean());
        list.add(new AppointmentBean());
        list.add(new AppointmentBean());
        appointmentAdapter = new AppointmentAdapter(R.layout.item_appointment_layout, list);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(appointmentAdapter);
        appointmentAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                switch (view.getId()) {
                    case R.id.ll_shop:
                        ToastUtil.ToastShort(position + "");
                        Intent intent = new Intent(AppointmentActivity.this, AppointmentMessageActivity.class);
                        startActivity(intent);
                        break;
                    default:
                        break;
                }
            }
        });
    }

    @Override
    public int getContentView() {
        return R.layout.activity_appointment;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_finish_appointment:
                finish();
                break;
            case R.id.tv_comment_appointment:
                ToastUtil.ToastShort("评论最多");
                break;
            case R.id.tv_distance_appointment:
                ToastUtil.ToastShort("距离");
                break;
        }
    }
}
